#!/bin/bash
datetime=`date +"%Y-%m-%d"`
#同步日志输出
#exec > /var/log/yum-update.log
echo "begin sync at $datetime"
dest_dir=/var/www/yum/
targetid=centos7
#同步镜像源
reposync -d --download_path=$dest_dir/$targetid \
--repoid=base --repoid=extras --repoid=updates

createrepo -update $dest_dir/$targetid

targetid=cloud

reposync -d --download_path=$dest_dir/$targetid \
--repoid=centos-ceph-jewel \
--repoid=centos-openstack-pike \
--repoid=centos-qemu-ev
createrepo -update $dest_dir/$targetid

targetid=epel

reposync -d --download_path=$dest_dir/$targetid \
--repoid=epel
createrepo -update $dest_dir/$targetid

targetid=mariadb

reposync -d --download_path=$dest_dir/$targetid \
--repoid=mariadb
createrepo -update $dest_dir/$targetid

chown -R apache:apache $dest_dir
chmod -R +x $dest_dir